<?php
/**
 * Created by PhpStorm.
 * User: wanglei
 * Date: 2016/4/9
 * Time: 17:16
 * 全局函数
 */

/**
 * 无线分类函数
 */
function getTree($menus){
    $items = array();
    foreach($menus as $menu){
        $items[$menu['id']] = $menu;
    }
    foreach($items as $key=>$item)
        $items[$item['pid']]['son'][$item['id']]=&$items[$item['id']];
    return isset($items[0]['son'])?$items[0]['son']:array();
}